<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>用户留言管理</title>
<link rel="stylesheet" href="resources/bootstrap.min.css">  
<script src="resources/jquery.min.js"></script>
<script src="resources/bootstrap.min.js"></script>
<script src="resources/layer/layer.js"></script>
</head>
<body>
	<div class="jumbotron text-center" style="margin-bottom:0">
		<h3>用户留言管理</h3>
		<table class="table table-bordered table-hover">
        <caption>•用户留言</caption>
	    <thead>
	        <tr>
	            <th class="text-center">留言主题</th>
	            <th class="text-center">留言者</th>
	            <th class="text-center">留言时间</th>
	            <th class="text-center">批量删除</th>
	        </tr>
	    </thead>
	    <tbody>
	    	<c:forEach var="a" items="${list}">
               <tr>
                  <td>${a.title}</td>
                  <td>${a.name}</td>
                  <td>${a.time}</td>
   				  <td><input type="checkbox" class="del" value="${a.id}"/></td>        
                </tr>
             </c:forEach>
	    </tbody>
	</table>
	<button type="button" class="btn btn-warning pull-right" onclick="del()">批量删除</button>
​
	</div>
</body>
</html>
<script>
/* 获取选中的对象，并删除对应的对象 */
function del(){
	var result="";
	var count=0;
	$(".del").each(function(){    
	    if($(this).is(':checked')){
	    	result+=$(this).val()+",";
	    	count++;
	    }
	  });
	if(result.charAt(result.length-1) == ",") result = result.substr(0,result.length-1);
	layer.confirm("确定删除这"+count+"条留言?",()=>{
		window.location.replace("delete?id="+result);
	});
}
</script>